package saveservice

import (
	"context"
	"errors"
	"gopkg.in/olivere/elastic.v5"
	"goruntimeDistributionCrawler/engine"
)

func SaveProfileData(item engine.Item,client *elastic.Client,index string) error  {

	if item.Type==""{
		return errors.New("must supply type")
	}
	_,err:=client.Index().
		Index(index).
		Type(item.Type).
		BodyJson(item.Payload).
		Id(item.Id).
		Do(context.Background())

	if err!=nil{
		return  err
	}

	return nil
}
